package com.nextel.project.cobranza.bean;

import pe.com.nextel.rms.DataInputStreamX;
import pe.com.nextel.rms.DataOutputStreamX;
import pe.com.nextel.rms.PersistenteX;
import java.io.IOException;

import org.kxml2.io.KXmlParser;
import org.kxml2.io.KXmlSerializer;
import pe.com.nextel.util.ArrayList;
import pe.com.nextel.util.Iterator;
import pe.com.nextel.util.List;
import pe.com.nextel.util.StringUtils;

/**
 *
 * @author eespinoza
 */
public class BancoBean extends   PersistenteX  {
    private String codigo;
    private String descripcion;
    
    public void persistir(DataOutputStreamX dataOutput, List list) throws IOException {
        dataOutput.writeInt(list.size());
        
        for (Iterator it = list.iterator(); it.hasNext();) {
            BancoBean bean = (BancoBean) it.next();
            bean.persistirItem(dataOutput);
        }
    }
    
    public List recuperar(DataInputStreamX dataInput) throws IOException {
        List lista = new ArrayList();
        BancoBean bean = null;
        
        int cant = dataInput.readInt();
        for (int i = 0; i < cant; i++) {
            bean = new BancoBean();
            bean.recuperarItem(dataInput);
            lista.add(bean);
        }
        
        return lista;
    }
    
    public void persistirItem(DataOutputStreamX dataOutput) throws IOException {
        
        
        dataOutput.writeString(StringUtils.stringNullToBlank(getCodigo()));
        dataOutput.writeString(StringUtils.stringNullToBlank(getDescripcion()));
        
        
    }
    
    public void recuperarItem(DataInputStreamX dataInput) throws IOException {
        
        
        setCodigo(dataInput.readString());
        setDescripcion(dataInput.readString());
        
        
    }
    public void writeXMLObject(KXmlSerializer writer) throws IOException {
    }
    public void readXMLObject(KXmlParser parser) throws IOException {
        
        
        setCodigo(parser.getAttributeValue(null, "c"));
        setDescripcion(parser.getAttributeValue(null, "d"));
        
    }
    
    public String getCodigo() {
        return codigo;
    }
    
    public void setCodigo(String codigo) {
        this.codigo = codigo;
    }
    
    public String getDescripcion() {
        return descripcion;
    }
    
    public void setDescripcion(String descripcion) {
        this.descripcion = descripcion;
    }
    
    
}
